from django.db import models

class Student(models.Model):
    student_id = models.CharField(max_length=20, unique=True, verbose_name='学号')
    name = models.CharField(max_length=50, verbose_name='姓名')
    class_name = models.CharField(max_length=50, verbose_name='班级')
    gender = models.CharField(max_length=10, choices=[('M', '男'), ('F', '女')], verbose_name='性别')
    date_of_birth = models.DateField(verbose_name='出生日期')
    admission_date = models.DateField(verbose_name='入学日期')
    phone = models.CharField(max_length=15, blank=True, null=True, verbose_name='联系电话')
    email = models.EmailField(blank=True, null=True, verbose_name='电子邮箱')
    address = models.TextField(blank=True, null=True, verbose_name='家庭住址')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')

    class Meta:
        verbose_name = '学生'
        verbose_name_plural = '学生'
        ordering = ['student_id']

    def __str__(self):
        return f"{self.student_id} - {self.name}"
